#coding=utf8

from base import TBase

class TradeRate(TBase):
    typename = 'traderate'
    fields='valid_score,tid,oid,role,nick,result,created,rated_nick,item_title,item_price,content,reply'
    def get(self, sessionkey, fields='', 
            rate_type='get', role='buyer', 
            start='', end='', 
            page_no=1, page_size=200):
        self.session = sessionkey
        self.method = 'traderates.get'
        if fields: 
            self.setParams(fields = fields)
        if start:
            self.setParams(start_date = start)
        if end:
            self.setParams(end_date = end)
        self.setParams(rate_type=rate_type)
        self.setParams(role=role)
        self.setParams(page_no=page_no)
        self.setParams(page_size=page_size)
        return self.do()


if __name__ == '__main__':
    a = TradeRate()
    import json
    fw = open('aaaaaaaaaaaa.json', 'w')
    #print a.get('6100e17d82db4042e22c805c9106b732e62a47987623157653848668')
    #print a.get('6100a16e379b468aabf9454419c60b991534ec02b02c4da99294966')
    json.dump(a.get('6100e25d9aeb7df743c097e22cf7416ea1a31280eb68b79354823861'), fw)
